package com.learn.mapstruct.condition.kit;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.learn.mapstruct.condition.model.ConditionEntity;
import lombok.experimental.UtilityClass;
import org.mapstruct.Condition;
import org.mapstruct.Context;
import org.mapstruct.Named;

@UtilityClass
public class ConditionKit {

    @Condition
    @Named("condition1")
    public boolean condition1(String value) {
        return StrUtil.isNotBlank(value);
    }

    @Condition
    @Named("condition2")
    public boolean condition2(Long value) {
        return value != null;
    }

    @Condition
    @Named("condition3")
    public boolean condition3(Object value) {
        return ObjectUtil.isNotEmpty(value);
    }

    @Condition
    @Named("condition4")
    public boolean condition4(Object value, @Context Object data) {
        return ObjectUtil.isNotEmpty(value);
    }

    @Condition
    @Named("condition5")
    public boolean condition5(ConditionEntity entity) {
        return entity != null;
    }
}
